<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class About extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
    }
    
    public function index(){
        $data['title'] = 'about';
        $data['content'] = $this->load->view('about/about','',TRUE);
        $this->load->view('front',$data);
    }
    
    public function visimisi(){
        $data['title'] = 'Vision & Mission';
        $data['content'] = $this->load->view('about/visimisi','',TRUE);
        $this->load->view('front',$data);
    }
    
    public function contact(){
        $data['title'] = 'contact';
        $data['content'] = $this->load->view('about/contact','',TRUE);
        $this->load->view('front',$data);
    }
    
    public function apatau(){
        $data['title'] = 'apatau';
        $data['content'] = $this->load->view('about/apatau','',TRUE);
        $this->load->view('front',$data);
    }
    
    public function submit(){
        $this->load->model('projects');
        $input['nama'] = $this->input->post('nama');
        $input['email'] = $this->input->post('email');
        $input['hp'] = $this->input->post('hp');
        $input['project'] = $this->input->post('project');
        $input['deskripsi'] = $this->input->post('deskripsi');
        $input['budget'] = $this->input->post('budget');
        $input['start'] = $this->input->post('start');
        $input['end'] = $this->input->post('end');
        $this->projects->add($input);
        
        // setting configuration email
        $this->load->library('email');
        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'mail.inkubatorit.com';
        $config['smtp_user'] = 'inkutcom';
        $config['smtp_pass'] = 'ink32132';
        $config['smtp_port'] = '25';
        $config['mailtype'] = 'text';
        $config['wordwrap'] = TRUE;
        $this->email->initialize($config);
        $to      = 'marketing@inkubatorit.com';
        $subject = 'Project '.$input['project'];
        $message =  'Salam ' ."\r\n"
                    .'Nama : ' .$input['nama'] ."\r\n"
                    .'Email : ' .$input['email'] ."\r\n"
                    .'No Hp : ' .$input['hp'] ."\r\n"
                    .'Mengajukan projek dengan deskripsi sebagai berikut :' ."\r\n"
                    .$input['deskripsi'] . "\r\n" 
                    .'Dengan anggaran : Rp ' .$input['budget'] . "\r\n"
                    .'Dengan waktu pengerjaan : ' .$input['start'] .' sampai dengan ' .$input['end'] . "\r\n"
                    .'Terima kasih' ."\r\n"
                    .'--Ini adalah pesan automatis dari web inkubator IT--';
        $this->email->to($to);
        $this->email->from('webmaster@inkubatorit.com');
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->send();
        $this->apatau();
    }
}